package com.ehotting.eaf.core.snow;


import java.math.BigDecimal;
import java.math.BigInteger;



public class ConvertNumUtil {

    private static String S64BASE = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ@#";

    public static String to64String(BigInteger i) {
        BigDecimal divide = new BigDecimal(64);
        BigDecimal decimal = new BigDecimal(i);
        String res = "";
        // 循环取余
        while (BigDecimal.ZERO.compareTo(decimal) != 0) {
            BigDecimal[] divRes = decimal.divideAndRemainder(divide);// 返回数组：[0] 商值(this / val) ， [1] 余数(this % val)
            decimal = divRes[0];
            res = S64BASE.charAt(divRes[1].intValue()) + res;
        }
        return res;
    }

}

